import * as actionTypes from '../../actions/ActionTypes';

import { handleActions } from 'redux-actions';


const defData = {  //职位推荐初始值
    postionCollectList:[]
}

export const ShowPostionCollect = handleActions({
    [actionTypes.SEL_POSTION_COLLECT]: {
        next(state, action) {
            if(action.payload.page!=1){//不是第一页时追加postionCollectList
                action.payload.postionCollectList = state.data.postionCollectList.concat(action.payload.postionCollectList);
            }
            return { ret: true, isloading:false, data: action.payload };
        },
        throw(state, action) {
            return { ret: false, isloading:false, data: defData };
        }
    },
    [actionTypes.SEND_POSTION_COL]: {
        next(state, action) {
            if(action.payload.page!=1){//不是第一页时追加postionCollectList
                action.payload.postionCollectList = state.data.postionCollectList.concat(action.payload.postionCollectList);
            }
            return { ret: true, isloading:false, data: action.payload };
        },
        throw(state, action) {
            return { ret: false, isloading:false, data: defData };
        }
    }
}, { ret: true, isloading:true, data: defData });

const defData1 = {  //谁看了我的简历
    resumeBrowseList:[]
}

export const SelWhoSawMeMoble = handleActions({
    [actionTypes.SEL_WHOSAWME_MOBLE]: {
        next(state, action) {
            if(action.payload.page!=1){//不是第一页时追加resumeBrowseList
                action.payload.resumeBrowseList = state.data.resumeBrowseList.concat(action.payload.resumeBrowseList);
            }
            return { ret: true, isloading:false, data: action.payload };
        },
        throw(state, action) {
            return { ret: false, isloading:false, data: defData1 };
        }
    }
}, { ret: true, isloading:true, data: defData1 });

const defData2 = {  //我关注的企业
    companyFollowList:[]
}

export const SelFollowMob = handleActions({
    [actionTypes.SEL_FOLLOW_MOBLE]: {
        next(state, action) {
            if(action.payload.page!=1){//不是第一页时追加companyFollowList
                action.payload.companyFollowList = state.data.companyFollowList.concat(action.payload.companyFollowList);
            }
            return { ret: true, isloading:false, data: action.payload };
        },
        throw(state, action) {
            return { ret: false, isloading:false, data: defData2 };
        }
    }
}, { ret: true, isloading:true, data: defData2 });